/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.user
 * UserController.java
 * 创建人:小胡
 * 时间：2016年12月06日 18:16:52
 */
package com.tz.web.user;
import com.tz.auth.AuthPassport;
import com.tz.bean.TzParams;
import com.tz.bean.User;
import com.tz.service.user.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 会员管理web
 * UserController
 * 创建人:小胡
 * 时间：2016年12月06日 18:16:52
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/user/user")
public class UserController {
	
	@Autowired
	private IUserService userService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params,Model model){
		model.addAttribute("params",params);
		return "user/user/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		model.addAttribute("datas", userService.findUsers(params));
		model.addAttribute("itemCount", userService.count(params));
		return "user/user/template";
	}


	@AuthPassport
	@ResponseBody
	@RequestMapping(value="/update",method= RequestMethod.POST)
	public String update(User user){
		int n = userService.update(user);
		return "success";
	}


	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		userService.delete(params);
		return "success";
	}
}
